<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%@ include file="/common/grid/jqGrid.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="">
	<meta http-equiv="description" content="This is my page">
	
  </head>
  
  <body>
    	<s:form name="frm" id="frm" method="post" action="" namespace="">
    		<jsp:include page="/jsp/outward/business/common/menuLink.jsp">
    			<jsp:param name="menuLink" value="[{'name':'调查问卷'},{'name':'问卷应用'},{'name':'问卷实例'}]"/>
    			<jsp:param name="width" value="40%"/>
    		</jsp:include>
    		
    		<s:hidden name="pvo.paperId" id="paperId"></s:hidden>
    		
    		<table cellspacing="1" width="100%" bgcolor="#CCCCCC">
				<tr bgcolor="#FFFFFF">
					<td align="right" width="10%" class="label">
						问卷编号：
					</td>
					<td align="left" width="23%">
						<s:textfield id="pfCode" cssStyle="width:80%" cssClass="search"></s:textfield>
					</td>
					<td align="right" width="10%" class="label">
						姓名：
					</td>
					<td align="left" width="23%">
						<s:textfield id="pfName" cssStyle="width:80%" cssClass="search"></s:textfield>
					</td>
					<td align="right" width="10%" class="label">
						性别：
					</td>
					<td align="left" width="24%">
						<s:select list='#{"男":"男","女":"女"}' cssStyle="width:80px;" id="pfSex" headerKey="" headerValue="--请选择--" cssClass="search"></s:select>
					</td>
				</tr>
			</table>
			<table cellspacing="0" width="100%">
				<tr>
					<td align="left">
    					<input type="button" value="新增" class="btn" onclick="addPaperFix()" />
    					<input type="button" value="查询" class="btn" onclick="searchThis()" />
    					<input type="button" value="重置" class="btn" onclick="resetSearch()" />
    				</td>
    			</tr>
    		</table>
    		<table id="list" cellpadding="3" cellspacing="0"></table>
			<div id="pager" style="text-align:center;"></div>
    	</s:form>
    
    <script type="text/javascript">
    $(document).ready(function(){
        var cName = new Array('问卷编号','姓名', '性别', '时间', '操作');
    	var cModel = [
    					{name:'pfCode', index:'pfCode', width:'20%', align:'center'},  
    					{name:'pfName', index:'pfName', width:'20%', align:'center'},
                        {name:'pfSex', index:'pfSex', width:'20%', align:'center'},
                        {name:'pfTime', index:'pfTime', width:'20%', align:'center', formatter:'date', formatoptions:{srcformat:'Y-m-d H:i:s', newformat:'Y-m-d H:i:s'}},
                        {name:'id', index:'id', width:'20%', align:'center', sortable:false, formatter:option}
                      ];
        
        newJqGrid({
        	id: 'id',
        	gridId: 'list',
        	pagerId: 'pager',
        	url: 'inner/qes/paperInstanceListByPage.action?pvo.paperId=' + $('#paperId').val(),
        	head: cName,
        	column: cModel,
        	width: getBodyWidth(),
        	height: 'auto',
        	hasCb: false,
        	title: '问卷列表'
        });
        
        $(window).resize(function(){
        	gridAutoWidth('list', 'win');
        });
    });
    
    function option(cellVal, options, row)
    {
    	var html = '<a href="javascript:updatePaperFix(\'' + row['id'] + '\')" >修改</a>';
    	html += ' <a href="javascript:delPaperFix(\'' + row['id'] + '\')" >删除</a>';
    	return html;
    }
    
    function updatePaperFix(id)
    {
    	var url = realPath + '/inner/qes/toUpdatePaperFix.action?paperFix.id=' + id;
    	window.location.href = url;
    }
    
    function searchThis()
    {
    	var params = {
    		'pvo.pfCode':$('#pfCode').val(),
    		'pvo.pfName':$('#pfName').val(),
    		'pvo.pfSex':$('#pfSex').val()
    	};
    	toSearchList('list', params);
    }

    function addPaperFix()
    {
        var url = realPath + '/inner/qes/toAddPaperFix.action?paperFix.paper.id=' + $('#paperId').val();
        showMd(url, 600, 300, 'yes', 'yes');
    }

    function delPaperFix(id)
    {
    	showConfirm('确认删除？', function(v){
        	if(v == true)
        	{
        		var url = 'inner/qes/delPaperFix.action?paperFix.id=' + id;
        		ajaxAction(url, 'get', 'frm', false, function(){
		    		searchThis();
		    	});
        	}
    	});
    }
    </script>
  </body>
</html>
